#!/bin/bash
cd ..
dist_dir=$(pwd)/dist/hc-cache-web
version=v1.0.0
env=product
tar_dir=$(pwd)/dist
tar_file=hc-cache-web-${version}-${env}.tar.gz

echo "正在编译..."
mvn clean package -P${env} -Dmaven.test.skip=true

echo "编译完成，正在拷贝war..."
rm -rf ${dist_dir}
mkdir -p ${dist_dir}
mkdir -p ${dist_dir}/logs
mkdir -p ${dist_dir}/bin
mkdir -p ${dist_dir}/webapp
cp ./script/start.sh ${dist_dir}/bin/
cp ./script/stop.sh ${dist_dir}/bin/
cp ./script/hc-cache-init.sh ${dist_dir}/bin/
cp ./hc-cache-web/target/hc-cache-web.war ${dist_dir}/webapp/hc-cache-web.war
chmod 755 ${dist_dir}/logs
chmod 644 ${dist_dir}/webapp/hc-cache-web.war
chmod 755 ${dist_dir}/bin/*.sh

echo "正在tar打包..."
rm -rf ${tar_dir}/${tar_file}
cd ${tar_dir} && tar -zcvf ${tar_file} ./hc-cache-web
echo "完成..."
